#pragma once

#ifndef __RPC_CLIENT_H__
#define __RPC_CLIENT_H__


#include "rpcstub.h"
#include <string>


class RpcClient;


class RpcClient {

protected:
    RPC_BINDING_HANDLE      m_hBinding;
    unsigned char          *m_pchBindingString;
    std::string             m_strSvcAddress;
    std::string             m_strSvcEndpoint;
    unsigned                m_errCode;
    std::string             m_errInfo;
    bool                    m_fIsConnected;

protected:
    RpcClient();
    RpcClient(__in std::string &svcAddress, __in std::string &svcEndpoint);
    ~RpcClient();
    void _SetErrCode(__in unsigned errCode);
    void _SetErrInfo(__in const char *errInfo);
    void _AddErrInfo(__in const char *errInfo);

private:
    bool _IdleCleanup();

protected:
    bool _Bind();
    bool _Unbind();

public:
    virtual bool Connect()  =0;
    virtual void Disconnect()   =0;
    
    bool Configure(__in std::string &svcAddress, __in std::string &svcEndpoint);
    bool InqIsBound();
    bool InqIsConnected();
    

protected:
    bool _SetIsConnected(__in bool fIsConnected);
    virtual bool _ConnectionProbe() = 0;
    virtual void _ConnectionPost() = 0;

};

#endif